package com.pda.xinma.adapter;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.pda.xinma.R;
import com.pda.xinma.bean.ArtificialListBean;
import com.pda.xinma.bean.EndFaceListBean;
import com.pda.xinma.ui.manmade.EndFaceDetailActivity;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.config.StringKey;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class EndFaceNewAdapter extends BaseAdapter<ArtificialListBean> {
    private String id;

    public EndFaceNewAdapter(int layoutResId, @Nullable List<ArtificialListBean> data) {
        super(layoutResId, data);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    protected void convert(BaseViewHolder helper, ArtificialListBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_storageBinId,item.getStorageBinId());
        RecyclerView recyclerView=helper.getView(R.id.rv_list);
        EndFaceAdapter endFaceAdapter=new EndFaceAdapter(R.layout.item_man_made, item.getDeliveryVos());
        recyclerView.setAdapter(endFaceAdapter);
        endFaceAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                ArtificialListBean.DeliveryVosBean endFaceListBean = endFaceAdapter.getData().get(position);
                endFaceListBean.setCenterCode(id);
                Bundle bundle = new Bundle();
                bundle.putSerializable(StringKey.QQ, endFaceListBean);
                Intent intent=new Intent(getContext(), EndFaceDetailActivity.class);
                intent.putExtras(bundle);
                getContext().startActivity(intent);
                //startIntent(AppActivityKey.ENDFACEDETAILACTIVITY, bundle);
            }
        });
    }
}
